<?php 
Load::models('categoria');
class CategoriaController extends AppController 
{
    public function before_filter() {
        if ( !Auth::is_valid()){
            Router::redirect('usuario/login/');
        }else{
            $this->tipoMenu="categoria";
        }
    }
    
    public function index()
    {
        
    }
     public function agregar()
    {
        if(Input::hasPost('categoria')){
           
            $categoria = new Categoria(Input::post('categoria'));
            
             if(!$categoria->save()){
                Flash::error('Falló Operación');
                
                $this->categoria = $this->post('categoria');
              
            }else{
                Flash::success('Operación exitosa');
            }
        }
    }
    public function eliminar($id){
      
    }
    
    public function listar(){
         $categoria = new Categoria();
         $this->categoria =   $categoria->find("order: nombre");
    }
    
  
    
    
    
}
?>

